package com.fz.controller;

import com.fz.entity.Book;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by webrx on 2017-09-06.
 */
@Controller
public class User {
    /*@RequestMapping
    public String myuser(){   //这种情况找的是类名   http://localhost:8080/user
        System.out.println("mymymym");
        return "ok";
    }*/

    @RequestMapping("/zhuang") @ResponseBody         //http://localhost:8080/zhuang
    public String ai(){          //这种情况return就直接输出了
        return "I love you";
    }
    //重定向的演示
    @RequestMapping("/tian")
    public String tian(){
        System.out.println("tian");
        //return "redirect:/tian.jsp";   //输入的是http://localhost:8080/tian会自动跳转到http://localhost:8080/tian.jsp,
        //类似于resp.sendRedirect("tian.jsp")
        //return "tian";                //http://localhost:8080/tian
        //类似于req.getRequestDispatcher("tian.jsp").forword(req.resp);
        //return "redirect:tian.jsp";      //输入的是http://localhost:8080/tian会自动跳转到http://localhost:8080/tian.jsp
        return "redirect:tian/yy";      //输入的是http://localhost:8080/tian会自动跳转到http://localhost:8080/tian/yy

    }

@RequestMapping("/user/save") @ResponseBody
    public String save(Book book){
        System.out.println(book.getName());
        System.out.println(book.getPrice());
        return null;
    }
//注解也可以写在这个位置哦
    public @RequestMapping("/mys") @ResponseBody String mys(){
        return "我的位置哦iiii";
    }
}
